import React, { useState, useEffect } from "react";
import { Provider } from "react-redux";
import { SafeAreaView } from "react-native-safe-area-context"; // 安全边界
import Reactnavitor from "./src/navigator/Reactnavitor";
import { ThemeProvider } from '@rneui/themed';
import { init } from '@/utils/deviceStorage'
import store from './src/store';
import { getSafeChainInfo, getRPCNodeInfo } from "@/utils/safe-transfer/util";

export default function App() {

  const [isLoadEnd, setIsLoadEnd] = useState(false)

  useEffect(() => {
    //获取网络id
    getSafeChainInfo()
    //获取rpc网络节点
    getRPCNodeInfo().then(() => { init().then(() => { setIsLoadEnd(true) }) })
  }, [])

  return (
    <ThemeProvider>
      <SafeAreaView style={{ flex: 1 }}>
        <Provider store={store}>
          {isLoadEnd && <Reactnavitor />}
        </Provider>
      </SafeAreaView>
    </ThemeProvider>
  );
}

